#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'dong'


import requests

tsz_province = {
    34: "A安徽省",
    104: "B北京市",
    22: "C重庆市",
    26: "F福建省",
    24: "G广东省",
    49: "G甘肃省",
    43: "G广西省",
    44: "G贵州省",
    37: "H河北省",
    27: "H湖南省",
    28: "H湖北省",
    40: "H河南省",
    36: "H黑龙江省",
    39: "H海南省",
    25: "J江苏省",
    31: "J吉林省",
    35: "J江西省",
    30: "L辽宁省",
    42: "N内蒙古",
    45: "N宁夏",
    46: "Q青海",
    33: "S四川省",
    105: "S上海市",
    29: "S山东省",
    41: "S山西省",
    38: "S陕西省",
    3: "T天津市",
    48: "X西藏",
    47: "X新疆",
    32: "Y云南省",
    23: "Z浙江省",
}

url = 'http://www.360guakao.net/pub/area.html'

content_dict = []

for k, v in tsz_province.iteritems():
    data = {
        'id': k,
        'type': 'province'
    }
    print k

    r = requests.post(url, data=data)
    content_dict.append(r.content)

for v in content_dict:
    print v
    with open('a.txt', 'a+') as fd:
        fd.write(v)